#ifndef E_ITEM_MANAGER_H
#define E_ITEM_MANAGER_H

#include <DefineCommon.h>
#include <DefineLibCommon.h>
#include <EPlugin.h>
#include <EItem.h>

struct EItemManagerData;
/**This class manager EItem type.
 * The basic idea is to represent a EItem type by a EItem object.
 * A EItem type is a raw EItem object. The advantages of this idea are:
 * 1.EItem can be arranged as a tree struct
 * 2.EItem can storage additional infomation through ItemProperty and EVariant.
 * */
class COMMON_DLL EItemManager
{
public:

    static EItemManager* instance();

    void addToItemTypeRoot(EItemPtr itemType);

    EItemPtr getItemTypeRoot();
    EItemPtr getItemTreeRoot();
    EItemPtr getItemSettingRoot();

    /*Find the ItemType and new a EItem and return. So this class can be uesed as a class factory in global programing*/
    EItemPtr newItem(const EString& itemTypeName);
    EItemPtr newItem(long tagTypeItem);
    EItemPtr newItem(EItemPtr typeItemPtr);

    EItemPtr getItemByTag(EItemPtr rootItem, long tag);
    EItemPtr getItemByName(EItemPtr rootItem, const EString& name);

    //return the count of item that belong to same type
    int checkItemTypeCount(const EString& className);

protected:
    EItemManager();
    virtual ~EItemManager();

    static EItemManager* m_instance;
    EItemManagerData* m_data;

};

#endif // E_ITEM_MANAGER_H
